package com.example.enjoyarkuix.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import androidx.fragment.app.Fragment;

import com.example.enjoyarkuix.EntryCommonAbilityActivity;
import com.example.enjoyarkuix.ShowJumpActivity;
import com.example.enjoyarkuix.bean.ItemDataBean;
import com.example.enjoyarkuix.common.Constant;

import java.util.ArrayList;

public class BasesFragment extends Fragment {
    private final String TAG = this.getClass().getSimpleName();

    protected void judgePage(int position, ArrayList<ItemDataBean> arrayList) {
        ItemDataBean itemDataBean = arrayList.get(position);
        if (itemDataBean == null) {
            return;
        }
        int ItemJudgeType = itemDataBean.getItemJudgeType();
        try {
            Intent intent = new Intent();
            Bundle bundle = new Bundle();
            bundle.putSerializable("ItemDataBean", itemDataBean);//序列化
            intent.putExtras(bundle);//发送数据
            if (ItemJudgeType == Constant.JUDPT_SHOW_ACTIVITY) {
                intent.setClass(getContext(), ShowJumpActivity.class);
            } else if (ItemJudgeType == Constant.JUDPT_ENTRY_ENTRY_ABILITY_ACTIVITY) {
                intent.setClass(getContext(), EntryCommonAbilityActivity.class);
            } else if (ItemJudgeType == Constant.JUDPT_ANDROID_ACTIVITY) {
                Class c = itemDataBean.getClz();
                if (c == null) {
                    return;
                }
                intent.setClass(getContext(), c);
            } else {
                return;
            }
            startActivity(intent);
        } catch (Exception e) {
            Log.e(TAG, "onItemClick: " + e.toString());
        }
    }
}
